import request from '@/utils/request'

// job
export function jobList(params) {
  return request({
    url: '/bx/jobs',
    method: 'get',
    params
  })
}

export function addJob(data) {
  return request({
    url: '/bx/job',
    method: 'post',
    data
  })
}

export function preUpdateJob(data) {
  return request({
    url: '/bx/pre/job',
    method: 'put',
    data
  })
}

export function updateJob(data) {
  return request({
    url: '/bx/job',
    method: 'put',
    data
  })
}

export function deleteJob(id) {
  return request({
    url: '/bx/job/' + id,
    method: 'delete'
  })
}

export function runJobOnce(params) {
  return request({
    url: '/bx/job/once',
    method: 'get',
    params
  })
}

export function setJobOnline(id) {
  return request({
    url: '/bx/job/online/' + id,
    method: 'get'
  })
}

export function setJobOffline(id) {
  return request({
    url: '/bx/job/offline/' + id,
    method: 'get'
  })
}

export function atomFieldList(params) {
  return request({
    url: '/bx/atom_fields',
    method: 'get',
    params
  })
}

export function addAtomField(data) {
  return request({
    url: '/bx/atom_field',
    method: 'post',
    data
  })
}

export function preUpdateAtomField(data) {
  return request({
    url: '/bx/pre/atom_field',
    method: 'put',
    data
  })
}

export function updateAtomField(data) {
  return request({
    url: '/bx/atom_field',
    method: 'put',
    data
  })
}

export function deleteAtomField(id) {
  return request({
    url: '/bx/atom_field/' + id,
    method: 'delete'
  })
}

export function displayFieldList(params) {
  return request({
    url: '/bx/display_fields',
    method: 'get',
    params
  })
}

export function addDisplayField(data) {
  return request({
    url: '/bx/display_field',
    method: 'post',
    data
  })
}

export function preUpdateDisplayField(data) {
  return request({
    url: '/bx/pre/display_field',
    method: 'put',
    data
  })
}

export function updateDisplayField(data) {
  return request({
    url: '/bx/display_field',
    method: 'put',
    data
  })
}

export function deleteDisplayField(id) {
  return request({
    url: '/bx/display_field/' + id,
    method: 'delete'
  })
}

export function dictList() {
  return request({
    url: '/bx/dict',
    method: 'get'
  })
}
export function numericDictList() {
  return request({
    url: '/bx/dict/numeric',
    method: 'get'
  })
}

export function updateDict(data) {
  return request({
    url: '/bx/dict',
    method: 'put',
    data
  })
}

// data

export function jobFilters(id) {
  return request({
    url: '/bx/data/filters/' + id,
    method: 'get'
  })
}

export function rawJobData(id) {
  return request({
    url: '/bx/data/raw/' + id,
    method: 'get'
  })
}

export function jobData(id, params) {
  return request({
    url: '/bx/data/' + id,
    method: 'get',
    params
  })
}
